package com.itheima.xiancheng;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable mc=new MyCallable();

        FutureTask<String>  f=new FutureTask<String>(mc);
        Thread t=new Thread(f);
        t.start();
        String s = f.get(); //线程结束后才能执行get方法
        System.out.println(s);

//        MyCallable  mc1=new MyCallable(); //开启多线程，该对象不需要重新创建
        FutureTask<String>  f1=new FutureTask<String>(mc);
        Thread t1=new Thread(f1);
        t1.start();
        String s1 = f1.get();
        System.out.println(s1);
    }
}
